package otcv.hr.webapp.dao;

import java.sql.SQLException;

import otcv.hr.log.Logger;
import otcv.hr.webapp.entity.LoginEntity;
import otcv.hr.webapp.entity.LoginSchEntity;

/**
 * @author : H-Thien
 * @comment : Login Data Access Object
 */
public class LoginDAO extends Dao {

	/**
	 * @comment : login Head
	 */
	public LoginEntity login(LoginSchEntity key) throws SQLException {
		LoginEntity login = null;

		try {
			login = (LoginEntity) sqlMap.queryForObject("login.loginStaff", key);
		} catch (SQLException e) {
			Logger.error("[LoginDAO]loginStaff, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {
			sqlMap.endTransaction();
		}

		return login;
	}

	/**
	 * @comment : login Agent
	 */
	public LoginEntity loginChkAgent(LoginSchEntity key) throws SQLException {
		LoginEntity login = null;

		try {
			login = (LoginEntity) sqlMap.queryForObject("login.loginChkAgent", key);
		} catch (SQLException e) {
			Logger.error("[LoginDAO]loginChkAgent, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {
			sqlMap.endTransaction();
		}

		return login;
	}

	/**
	 * @comment : login Store
	 */
	public LoginEntity loginChkStore(LoginSchEntity key) throws SQLException {
		LoginEntity login = null;

		try {
			login = (LoginEntity) sqlMap.queryForObject("login.loginChkStore", key);
		} catch (SQLException e) {
			Logger.error("[LoginDAO]loginChkStore, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {
			sqlMap.endTransaction();
		}

		return login;
	}

	/**
	 * @comment : login Advertiser
	 */
	public LoginEntity loginChkAdvertiser(LoginSchEntity key) throws SQLException {
		LoginEntity login = null;

		try {
			login = (LoginEntity) sqlMap.queryForObject("login.loginChkAdvertiser", key);
		} catch (SQLException e) {
			Logger.error("[LoginDAO]loginChkAdvertiser, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {
			sqlMap.endTransaction();
		}

		return login;
	}

}